package com.jorado.metrics.util;

public class TimeHelp {

    /**
     * Number of nanoseconds in a second.
     */
    public static final double NANOSECONDS_PER_SECOND = 1E9;


    /**
     * Number of milliseconds in a second.
     */
    public static final double MILLISECONDS_PER_SECOND = 1E3;

    /**
     * 秒为单位的监控区间示例
     */
    public static final double[] histogram_time_second = new double[]{0.001, 0.005, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 2.0, 3.0, 4.0, 5.0};

    /**
     * 纳秒转秒
     *
     * @param nanoseconds
     * @return
     */
    public static double nanSecondsToSecond(double nanoseconds) {
        return nanoseconds / NANOSECONDS_PER_SECOND;
    }

    /**
     * 毫秒转秒
     *
     * @param milliseconds
     * @return
     */
    public static double milliToSecond(double milliseconds) {
        return milliseconds / MILLISECONDS_PER_SECOND;
    }

}
